package cn.easthome.demo.service;

import cn.easthome.demo.bean.User;
import cn.easthome.demo.dao.IUserDao;
import cn.easthome.demo.dao.UserDaoImpl;

import java.util.List;

//实现IUserService接口
public class UserServiceImpl implements IUserService{
    private IUserDao userDao;
    // 登录验证
    @Override
    public boolean isCheckLogin(String username, String password) {
        //1.查询数据表中的所有
        userDao=new UserDaoImpl();
        List<User> list=userDao.findAll();
        //2.遍历，判断用户名密码是否正确
        for(User user:list){
            if(user.getUsername().equals(username)&&user.getPassword().equals(password)){
                return true;
            }
        }
        //匹配成功返回true
        //匹配失败返回false
        return false;
    }
}
